package com.icode.core.model;

import com.icode.core.shared.usertype.StringsUserType;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.HashSet;
import java.util.Set;

/**
 * User: alexz
 * Date: 2015/9/29
 * Time: 17:18
 */
@Entity
@Table(name = "protected_urls")
@TypeDefs({@TypeDef(name = "SingleColumnStrings", typeClass = StringsUserType.class,
        parameters = {@Parameter(name = "delimiter", value = ","),
                @Parameter(name = "collectionType", value = "java.util.HashSet"),
                @Parameter(name = "elementType", value = "java.lang.String")})})
public class ProtectedURLs extends AbstractEntity {
    @Column(name = "urls")
    @Type(type = "SingleColumnStrings")
    private Set<String> url = new HashSet<>();
    @Column(name = "method")
    private String method;
    @Column(name = "authorities")
    @Type(type = "SingleColumnStrings")
    private Set<String> authorities = new HashSet<>();

    public ProtectedURLs() {
    }

    public ProtectedURLs(Set<String> url, String method, Set<String> authorities) {
        this.url = url;
        this.method = method;
        this.authorities = authorities;
    }

    public Set<String> getUrl() {
        return url;
    }

    public String getMethod() {
        return method;
    }

    public Set<String> getAuthorities() {
        return authorities;
    }
}
